package basic_practice_1023;

import java.util.Scanner;
/**
 * @author MemoryC
 * */

public class Main {

	public static void main(String[] args) {

		Scanner scanner=new Scanner(System.in);
		
		long[]A=new long[21];
		A[0]=0;
		A[1]=0;
		A[2]=1;
		for(int i=3,flag=-1;i<21;i++,flag*=-1) {
			A[i]=i*A[i-1]+flag;
		}
		
		while(scanner.hasNext()) {
			int n=scanner.nextInt();
			int m=scanner.nextInt();
			
			long result=Cni(n, m)*A[m];
			
			System.out.println(result);
		}
		scanner.close();
    }
	static long Cni(int n,int i) {
		if(i>n/2) {
			return Cni(n, n-i);
		}
		long A=1;
		for(int j=n;j>n-i;j--) {
			A*=j;
		}
		for(int j=i;j>0;j--) {
			A/=j;
		}
		return A;
	}
}